// <copyright file="PackageFolderTest.cs" company="Bill Fellows">
// Copyright (c) But not really, use it as you see fit. All rights reserved.
// </copyright>
namespace SSISDeploy.Components.Tests
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    using SSISDeploy.Components;
    using NUnit.Framework;

    /// <summary>
    /// This class is responsible for testing our PackageFolder class.  Currently, this is overkill
    /// but provided for completeness
    /// </summary>
    [TestFixture]
    public class PackageFolderTest
    {
        /// <summary>
        /// An instance of the class to be tested
        /// </summary>
        private PackageFolder packageFolder;

        /// <summary>
        /// Perform initialization tasks
        /// </summary>
        [TestFixtureSetUp]
        public void Initialize()
        {
            // Console.WriteLine("I am Initialize");
            this.packageFolder = new PackageFolder();
        }

        /// <summary>
        /// Per test setup step
        /// </summary>
        [NUnit.Framework.SetUp]
        public void TestInitialze()
        {
            // Console.WriteLine("I am TestInitialize");
            this.packageFolder.IsFolder = false;
            this.packageFolder.IsPackage = false;
            this.packageFolder.CreateDate = string.Empty;
            this.packageFolder.Name = string.Empty;
            this.packageFolder.Path = string.Empty;
            this.packageFolder.Version = string.Empty;
        }

        /// <summary>
        /// Evaulate the CreateDate property
        /// </summary>
        [Test]
        public void CreateDate()
        {
            DateTime validDate = DateTime.MinValue;
            this.packageFolder.CreateDate = validDate.ToString();
            Assert.AreEqual(this.packageFolder.CreateDate, validDate.ToString());
        }

        /// <summary>
        /// Evaluate the IsPackage property
        /// </summary>
        [Test]
        public void IsPackage()
        {
            this.packageFolder.IsFolder = true;
            this.packageFolder.IsPackage = true;
            Assert.IsTrue(this.packageFolder.IsPackage);
            Assert.IsFalse(this.packageFolder.IsFolder);

            this.packageFolder.IsPackage = false;
            Assert.IsFalse(this.packageFolder.IsPackage);
            Assert.IsFalse(this.packageFolder.IsFolder);
        }

        /// <summary>
        /// Evaluate the IsFolder property
        /// </summary>
        [Test]
        public void IsFolder()
        {
            this.packageFolder.IsPackage = true;
            this.packageFolder.IsFolder = true;
            Assert.IsTrue(this.packageFolder.IsFolder);
            Assert.IsFalse(this.packageFolder.IsPackage);

            this.packageFolder.IsFolder = false;
            Assert.IsFalse(this.packageFolder.IsPackage);
            Assert.IsFalse(this.packageFolder.IsFolder);
        }

        /// <summary>
        /// Test the setting and retrieval of name
        /// </summary>
        [Test]
        public void Name()
        {
            Assert.IsEmpty(this.packageFolder.Name);
            this.packageFolder.Name = "Icarus";
            Assert.IsNotEmpty(this.packageFolder.Name);
        }

        /// <summary>
        /// Test the setting and retrieval of path
        /// </summary>
        [Test]
        public void Path()
        {
            Assert.IsEmpty(this.packageFolder.Path);
            this.packageFolder.Path = "Sun";
            Assert.IsNotEmpty(this.packageFolder.Path);
        }

        /// <summary>
        /// Test the setting and retrieval of name
        /// </summary>
        [Test]
        public void Version()
        {
            Assert.IsEmpty(this.packageFolder.Version);
            this.packageFolder.Version = "1.0";
            Assert.IsNotEmpty(this.packageFolder.Version);
        }

        /// <summary>
        /// Test the ToString method
        /// </summary>
        [Test]
        public void ToStringTest()
        {
            string folderMessage = "Folder:  Sample";
            string packageMessage = "Package:  Sample v1.0 ";
            this.packageFolder.Name = "Sample";
            this.packageFolder.IsFolder = true;
            Assert.AreEqual(this.packageFolder.ToString(), folderMessage);

            this.packageFolder.Version = "1.0";
            this.packageFolder.Path = @"some\path";
            this.packageFolder.IsPackage = true;
            Assert.AreEqual(this.packageFolder.ToString(), packageMessage);
        }
    }
}
